package framework.multimedia;

import framework.FRDJPanel;
import framework.FRDModel;
import java.io.Serializable;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author Lukáš Marek
 */
public class FRDMultimedia extends FRDJPanel implements Serializable
{
	protected FRDMultimediaModel model = null;

	/**
	 * Vytvori novy panel FRDMultimedia
	 */
	public FRDMultimedia()
	{
		initComponents();
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents()
  {

    jPanel1 = new javax.swing.JPanel();
    jItemPanel = new javax.swing.JPanel();
    jItemPanel2 = new javax.swing.JPanel();
    jItemPanel3 = new javax.swing.JPanel();
    jItemPanel5 = new javax.swing.JPanel();
    jItemPanel1 = new javax.swing.JPanel();
    jItemPanel4 = new javax.swing.JPanel();
    addButton = new javax.swing.JButton();
    jPanel2 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    nameTextField = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    searchButton = new javax.swing.JButton();
    imageTextField = new javax.swing.JTextField();
    jButton2 = new javax.swing.JButton();
    pagerButtonLeft = new javax.swing.JButton();
    pagerButtonRight = new javax.swing.JButton();
    pagerLabel = new javax.swing.JLabel();

    jPanel1.setBackground(new java.awt.Color(255, 255, 255));
    jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jPanel1.setPreferredSize(new java.awt.Dimension(800, 480));
    jPanel1.setLayout(null);

    jItemPanel.setPreferredSize(new java.awt.Dimension(240, 210));

    javax.swing.GroupLayout jItemPanelLayout = new javax.swing.GroupLayout(jItemPanel);
    jItemPanel.setLayout(jItemPanelLayout);
    jItemPanelLayout.setHorizontalGroup(
      jItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );
    jItemPanelLayout.setVerticalGroup(
      jItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 210, Short.MAX_VALUE)
    );

    jPanel1.add(jItemPanel);
    jItemPanel.setBounds(20, 20, 240, 210);

    jItemPanel2.setPreferredSize(new java.awt.Dimension(240, 210));

    javax.swing.GroupLayout jItemPanel2Layout = new javax.swing.GroupLayout(jItemPanel2);
    jItemPanel2.setLayout(jItemPanel2Layout);
    jItemPanel2Layout.setHorizontalGroup(
      jItemPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );
    jItemPanel2Layout.setVerticalGroup(
      jItemPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 210, Short.MAX_VALUE)
    );

    jPanel1.add(jItemPanel2);
    jItemPanel2.setBounds(540, 20, 240, 210);

    jItemPanel3.setPreferredSize(new java.awt.Dimension(240, 210));

    javax.swing.GroupLayout jItemPanel3Layout = new javax.swing.GroupLayout(jItemPanel3);
    jItemPanel3.setLayout(jItemPanel3Layout);
    jItemPanel3Layout.setHorizontalGroup(
      jItemPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );
    jItemPanel3Layout.setVerticalGroup(
      jItemPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 210, Short.MAX_VALUE)
    );

    jPanel1.add(jItemPanel3);
    jItemPanel3.setBounds(20, 250, 240, 210);

    jItemPanel5.setPreferredSize(new java.awt.Dimension(240, 210));

    javax.swing.GroupLayout jItemPanel5Layout = new javax.swing.GroupLayout(jItemPanel5);
    jItemPanel5.setLayout(jItemPanel5Layout);
    jItemPanel5Layout.setHorizontalGroup(
      jItemPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );
    jItemPanel5Layout.setVerticalGroup(
      jItemPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 210, Short.MAX_VALUE)
    );

    jPanel1.add(jItemPanel5);
    jItemPanel5.setBounds(540, 250, 240, 210);

    jItemPanel1.setPreferredSize(new java.awt.Dimension(240, 210));

    javax.swing.GroupLayout jItemPanel1Layout = new javax.swing.GroupLayout(jItemPanel1);
    jItemPanel1.setLayout(jItemPanel1Layout);
    jItemPanel1Layout.setHorizontalGroup(
      jItemPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );
    jItemPanel1Layout.setVerticalGroup(
      jItemPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 210, Short.MAX_VALUE)
    );

    jPanel1.add(jItemPanel1);
    jItemPanel1.setBounds(280, 20, 240, 210);

    jItemPanel4.setPreferredSize(new java.awt.Dimension(240, 210));

    javax.swing.GroupLayout jItemPanel4Layout = new javax.swing.GroupLayout(jItemPanel4);
    jItemPanel4.setLayout(jItemPanel4Layout);
    jItemPanel4Layout.setHorizontalGroup(
      jItemPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );
    jItemPanel4Layout.setVerticalGroup(
      jItemPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 210, Short.MAX_VALUE)
    );

    jPanel1.add(jItemPanel4);
    jItemPanel4.setBounds(280, 250, 240, 210);

    addButton.setText("Přidat");
    addButton.setActionCommand("addButton");

    jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    jLabel1.setText("Jméno");

    jLabel2.setText("Vyhledávání");

    jLabel3.setText("Obrázek");

    searchButton.setText("Vyhledat");
    searchButton.setActionCommand("searchButton");

    jButton2.setText("Vybrat");
    jButton2.addActionListener(new java.awt.event.ActionListener()
    {
      public void actionPerformed(java.awt.event.ActionEvent evt)
      {
        jButton2ActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
      jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel2Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(nameTextField)
          .addComponent(imageTextField)
          .addGroup(jPanel2Layout.createSequentialGroup()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
              .addComponent(jButton2)
              .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
              .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(0, 112, Short.MAX_VALUE))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
            .addGap(0, 0, Short.MAX_VALUE)
            .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)))
        .addContainerGap())
    );
    jPanel2Layout.setVerticalGroup(
      jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(36, 36, 36)
        .addComponent(jLabel3)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(imageTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jButton2)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 307, Short.MAX_VALUE)
        .addComponent(searchButton)
        .addContainerGap())
    );

    pagerButtonLeft.setText("<");
    pagerButtonLeft.setActionCommand("pagerButtonLeft");

    pagerButtonRight.setText(">");
    pagerButtonRight.setActionCommand("pagerButtonRight");

    pagerLabel.setText("1/1");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
              .addComponent(addButton, javax.swing.GroupLayout.Alignment.TRAILING))
            .addContainerGap())
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addComponent(pagerButtonLeft)
            .addGap(71, 71, 71)
            .addComponent(pagerLabel)
            .addGap(78, 78, 78)
            .addComponent(pagerButtonRight)
            .addGap(283, 283, 283))))
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(layout.createSequentialGroup()
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                .addGap(0, 25, Short.MAX_VALUE)
                .addComponent(addButton))
              .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                  .addComponent(pagerButtonLeft)
                  .addComponent(pagerButtonRight)
                  .addComponent(pagerLabel))
                .addGap(0, 0, Short.MAX_VALUE))))
          .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap())
    );
  }// </editor-fold>//GEN-END:initComponents

	/**
	 * Nacteni noveho obrazku
	 * @param evt 
	 */
  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed
  {//GEN-HEADEREND:event_jButton2ActionPerformed
		JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & PNG Images", "jpg", "png");
    chooser.setFileFilter(filter);
    int returnVal = chooser.showOpenDialog(this);
    if(returnVal == JFileChooser.APPROVE_OPTION)
		{
			imageTextField.setText(chooser.getSelectedFile().getAbsolutePath());
    }
  }//GEN-LAST:event_jButton2ActionPerformed
	

  // Variables declaration - do not modify//GEN-BEGIN:variables
  public javax.swing.JButton addButton;
  public javax.swing.JTextField imageTextField;
  private javax.swing.JButton jButton2;
  public javax.swing.JPanel jItemPanel;
  public javax.swing.JPanel jItemPanel1;
  public javax.swing.JPanel jItemPanel2;
  public javax.swing.JPanel jItemPanel3;
  public javax.swing.JPanel jItemPanel4;
  public javax.swing.JPanel jItemPanel5;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JPanel jPanel1;
  public javax.swing.JPanel jPanel2;
  public javax.swing.JTextField nameTextField;
  public javax.swing.JButton pagerButtonLeft;
  public javax.swing.JButton pagerButtonRight;
  private javax.swing.JLabel pagerLabel;
  public javax.swing.JButton searchButton;
  // End of variables declaration//GEN-END:variables
	/**
	 * Nastaveni modelu
	 * @param model
	 */
	@Override
	public void setModel(FRDModel model)
	{
		this.model = (FRDMultimediaModel) model;
	}

	/**
	 * vraci nastaveny model, pro praci nutno pretypovat
	 * @return
	 */
	@Override
	public FRDModel getModel()
	{
		return model;
	}

	/**
	 * nastaveni labelu s informaci o strance
	 * @param text 
	 */
	public void setPagerLabel(String text)
	{
		pagerLabel.setText(text);
	}
}
